package com.ykefu.assign.netty;

import io.netty.channel.Channel;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author likai
 * @date 2020/4/9 12:04
 * @email likai@7moor..com
 * @desc 连接存储器
 */
public class ChannelStore {

    /**
     * channel存储器
     */
    private static final ConcurrentHashMap<String, Channel> channelStore = new ConcurrentHashMap<>();

    public static void store(String id,Channel channel){
        channelStore.put(id,channel);
    }

    public static void remove(String id){
        channelStore.remove(id);
    }

    public static Channel getChannel(String id){
        return channelStore.get(id);
    }


    public static Collection<Channel> getChannels(){
        return channelStore.values();
    }

    public static ConcurrentHashMap<String, Channel> getChannelStore() {
        return channelStore;
    }
}
